//
//  myQuestHeaderView.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/8/6.
//

#import "myQuestHeaderView.h"
#import "questWeekView.h"
#import "myQuestListModel.h"

@interface myQuestHeaderView ()
@property (nonatomic ,strong) questWeekView * weekview;
@property (nonatomic ,strong) UILabel * leftLab;
@property (nonatomic ,strong) UILabel * rightLab;
@property (nonatomic ,strong) NSString * day;

@end
@implementation myQuestHeaderView

+ (instancetype)NewView{
    myQuestHeaderView * view = [myQuestHeaderView new];
    [view setupview];
    return view;
}
- (void)setupview{
    questWeekView * weekview = [questWeekView NewView];
    MJWeakSelf
    weekview.openTimeBlock = ^(NSString * _Nonnull day, NSString * _Nonnull startDay, NSString * _Nonnull endDay) {
//        if(weakSelf.openTimeBlock && ![weakSelf.day isEqualToString:day]){
        if(weakSelf.openTimeBlock ){
            weakSelf.day = day;
            weakSelf.openTimeBlock(day, startDay, endDay);
        }
    };
    self.weekview = weekview;
    [DTKTool YJ:kwt(5) andView:weekview];
    [self addSubview:weekview];
    [weekview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(kwt(10));
        make.right.offset(kwt(-10));
        make.height.offset(kwt(122));
    }];
   
    UIView * leftview = [UIView new];
    leftview.addClickBlock(^{
        [self opentkbz];
    });
    leftview.backgroundColor = UIColor.whiteColor;
    [DTKTool YJ:kwt(5) andView:leftview];
    [self addSubview:leftview];
    [leftview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(8));
        make.top.equalTo(weekview.mas_bottom).offset(kwt(10));
//        if( [UserInfoModel shared].userIdentity == 1){///员工不能筛选
//            make.width.offset(kwt(224));
//        } else {
            make.right.offset(kwt(-8));
//        }
        make.height.offset(kwt(37));
    }];
    
    UIImageView * leftImg = kimageView(@"tangkou_expand");
    [leftview addSubview:leftImg];
    [leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.right.offset(kwt(-10));
        make.width.height.offset(kwt(15));
    }];
    UILabel * leftLab = [DTKTool labelWithText:@"编组-全部池塘" andFont:kFont(15) andTextColor:KcolorHex(@"#222222")];
    self.leftLab = leftLab;
    [leftview addSubview:leftLab];
    [leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.right.offset(kwt(-45));
        make.left.offset(kwt(10));
    }];
//    
//    if([UserInfoModel shared].userIdentity == 1){///员工不能筛选
//        UIView * rightview = [UIView new];
//        rightview.addClickBlock(^{
//            [self openzxr];
//        });
//        rightview.backgroundColor = UIColor.whiteColor;
//        [DTKTool YJ:kwt(5) andView:rightview];
//        [self addSubview:rightview];
//        [rightview mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(leftview.mas_right).offset(kwt(10));
//            make.top.equalTo(weekview.mas_bottom).offset(kwt(10));
//            make.right.offset(kwt(-8));
//            make.height.offset(kwt(37));
//        }];
//        
//        UIImageView * rightImg = kimageView(@"tangkou_expand");
//        [rightview addSubview:rightImg];
//        [rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.offset(0);
//            make.right.offset(kwt(-10));
//            make.width.height.offset(kwt(15));
//        }];
//        UILabel * rightLab = [DTKTool labelWithText:@"执行人" andFont:kFont(15) andTextColor:KcolorHex(@"#222222")];
//        self.rightLab = rightLab;
//        [rightview addSubview:rightLab];
//        [rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.offset(0);
//            make.right.offset(kwt(-45));
//            make.left.offset(kwt(10));
//        }];
//    }
    
 
    
    
    
}


- (void)opentkbz{
    if(self.openTKBZBlock){
        self.openTKBZBlock();
    }
}
- (void)openzxr{
    if(self.openZXRlock){
        self.openZXRlock();
    }
}
- (void)setModel:(myQuestTimeListModel *)model{
    _model = model;
    self.weekview.model = model;
}
- (void)setUser:(NSString *)user{
    if(user.length > 0){
        self.rightLab.text = user;
    } else {
        self.rightLab.text = @"执行人";
    }
    
}
- (void)setXspondName:(NSString *)xspondName{
    if(xspondName.length > 0){
        self.leftLab.text = xspondName;
    } else {
        self.leftLab.text = @"编组-全部池塘";
    }
}
@end
